#!/bin/bash
echo "1:/htdoc/plugin/java/下的version号"
if [ "$1" == "" ]; then
	return
	exit
fi

#拷贝代码目录的proguard文件到当前目录
rm -rf ./proguard_riskstub.pro
cp ../../2source/RiskStub/proguard.cfg ./proguard_riskstub.pro
echo "copy proguard file"

rm -rf ./libs
mkdir libs
cp ../../2source/RiskStub/libs/* ./libs/
echo "copy libs"

java -jar /opt/sdk/tools/proguard/lib/proguard.jar @proguard_riskstub.pro
echo "proguard"

/opt/sdk/build-tools/19.1.0/dx --dex --output=RiskStub_dex.apk RiskStub.jar 
echo "dx"

base1="/opt/lampp/htdocs/plugin/java/"
base_ver="${base1}""$1"
name1="/RiskStub_dex.zip"
if [ ! -d $base_ver ]; then
	mkdir -p $base_ver
fi
cp ./RiskStub_dex.apk ${base_ver}${name1}
echo "copy to ""${base_ver}""${name1}"

base2="../../2source/everisk/bin/shell/plugin/java/"
base_ver2="${base2}""$1"
if [ ! -d $base_ver2 ]; then
	mkdir -p $base_ver2
fi
cp ./RiskStub_dex.apk ${base_ver2}${name1}
echo "copy to ""${base_ver2}""${name1}"

cp ./RiskStub_dex.apk ../../2source/everisk/tools/inject_shell/lib/RiskStub.apk
echo "copy to inject_shell/lib/RiskStub.apk"


